import { PureComponent } from "react"
import Com1 from "./com/com1"
import Com2 from "./com/com2"
import { CSSWrapper } from "./style"
import store from "../../store"
export default class Test1 extends PureComponent {
  constructor() {
    super()
    this.state = {
      age: store.getState().age
    }
  }
  componentDidMount() {
    store.subscribe(() => {
      console.log(store.getState().age)
      this.setState({
        // 强制触发视图更新
        age: store.getState().age
      })
    })
  }

  render() {
    return (
      <CSSWrapper>
        <header>Test1 header: {this.state.age}</header>
        <div className="flex">
          <div className="flex1">
            <Com1></Com1>
          </div>
          <div className="flex1">
            <Com2></Com2>
          </div>
        </div>
      </CSSWrapper>
    )
  }
}
